#include<bits/stdc++.h>
using namespace std;
int t;
double n,l,v;
int m;
struct node{
    double d0;
    double v0;
    double a0;
    double l0;
    double r0;
};
node a[100005];//4:l;  5:r;  1:d;  2:v;  3:a; 6:or
int b[100005];
int s[400005];
int vis[100005];
int ans;
int cnt;
void build(int s1,int l1,int r1,int k1){
    if(l1==r1&&l1==k1){
        s[s1]=1;
        return;
    }
    if(l1>k1||r1<k1) return;
    int mid=(l1+r1)/2;
    build(s1*2,l1,mid,k1);
    build(s1*2+1,mid+1,r1,k1);
    s[s1]=s[s1*2]+s[s1*2+1];
}

int find1(int s1,int l1,int r1,int x,int y){
    if(l1>=x&&r1<=y){
            vis[s1]++;
            return s[s1];
    }
    if(l1>y||r1<x) return 0;
    int mid=(l1+r1)/2;
    return find1(s1*2,l1,mid,x,y)+find1(s1*2+1,mid+1,r1,x,y);
}

int find2(int s1,int l1,int r1,int x,int y){
    if(vis[s1]==1) return 0;
    if(l1>=x&&r1<=y&&vis[s1]==0){
        vis[s1]=1;
        return s[s1];
    }
    if(l1>y||r1<x) return 0;
    int mid=(l1+r1)/2;
    return find2(s1*2,l1,mid,x,y)+find2(s1*2+1,mid+1,r1,x,y);
}

int zhen(double k){
    int f=k;
    return f;
}

int main(){
    freopen("detect1.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++){
            int p1,p2,p3;
        scanf("%d %d %d",&p1,&p2,&p3);
        a[i].d0=p1;
        a[i].v0=p2;
        a[i].a0=p3;
        a[i].l0=a[i].d0;
        if(a[i].v0<=v&&a[i].a0<=0) continue;
        if(a[i].v0>v&&a[i].a0>=0){
            a[i].r0=l;
            continue;
        }
        double f=(v*v-a[i].v0*a[i].v0)/(2*a[i].a0);
        if(a[i].v0>v&&a[i].a0<0){
            if(f>=(l-a[i].d0)) a[i].r0=l;
            else a[i].r0=f+a[i].d0;
            continue;
        }
        if(a[i].v0<v&&a[i].a0>0){
            if(f>=(l-a[i].d0)) continue;
            else{
                a[i].l0=f+a[i].d0;
                a[i].r0=l;
            }
        }
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&b[i]);
        build(1,1,l,b[i]);
    }
    for(int i=1;i<=n;i++){
        if(a[i].r0!=0){
                int f1=find1(1,1,zhen(l),zhen(a[i].l0)+1,zhen(a[i].r0));
                if(f1>0) ans++;
        }
    }
    sort(b+1,b+m+1);
    int p0;
    for(int i=1;i<=n;i++){
            if(a[i].r0==0) continue;
            int lll=zhen(a[i].l0);
            p0=0;
    int rrr=zhen(a[i].r0);
        for(int j=1;j<=m;j++){
            if(b[j]>=lll&&b[j]<=rrr){
                p0=j;
                if(vis[b[j]]==1) break;
            }
            else{
                vis[b[p0]]=1;
                break;
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(vis[i]==1) cnt++;
    }
    cout<<ans<<' '<<cnt+1<<endl;
    }
    return 0;
}
